<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>物业管理系统</title>
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<link rel="stylesheet" href="${pageContext.request.contextPath}/plugins/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/AdminLTE.min.css">
</head>
<style>
</style>
<body style="padding-bottom: 90px; background-color: #ECF0F5;">
	<div class="modal-content">
		<div class="modal-body">
			<div class="form-group">
				<label class="control-label">社区名称：</label> <input type="text" class="form-control" id="organizationName">
			</div>
			<div class="form-group">
				<label for="describe" class="control-label">负责人：</label> <input type="text" class="form-control" id="editAccount">
			</div>
			<div class="form-group">
				<label for="describe" class="control-label">备注：</label> <input type="text" class="form-control" id="remark">
			</div>
		</div>
	</div>
</body>
<script src="${pageContext.request.contextPath}/plugins/jQuery/jquery-2.2.3.min.js"></script>
<script src="${pageContext.request.contextPath}/plugins/bootstrap/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/js/date.js"></script>
<!-- layer -->
<script src="${pageContext.request.contextPath}/plugins/layer/2.4/layer.js"></script>
<script>
	var lock = false;
	var id = "${map['id']}";
	var index = parent.layer.getFrameIndex(window.name);
	$(function() {
		if (id != '') {
			$.ajax({
				url : "${pageContext.request.contextPath}/selectOrganizationById",
				type : "post",
				data : {
					id : id
				},
				dataType : "json",
				success : function(map) {
					var organization = map['organization'];
					$("#organizationName").val(organization.organizationName);
					$("#editAccount").val(organization.editAccount);
					$("#remark").val(organization.remark);
				}
			});
		}
	});

	//添加或修改
	function insertExplodingActivity() {
		lock = true;
		var organizationName = $("#organizationName").val();
		var editAccount = $("#editAccount").val();
		var remark = $("#remark").val();
		if (organizationName === '' || editAccount === '') {
			layer.alert("请填写社区名称，负责人!");
			lock = false;
			return;
		}
		$.ajax({
			url : '${pageContext.request.contextPath}/insertOrganization',
			type : "post",
			data : {
				organizationId : id,
				organizationName : organizationName,
				editAccount : editAccount,
				remark : remark
			},
			dataType : "json",
			success : function(data) {
				var result = data['result'];
				if (result == 1) {
					layer.msg('操作成功!', {
						icon : 1,
						time : 800
					});
					setTimeout(function() {
						parent.query();
						parent.layer.close(index);
					}, 1000);
				} else {
					layer.msg('操作失败!', {
						icon : 2,
						time : 800
					});
					lock = false;
				}
			}
		});
	}

	function insert() {
		if (!lock) {
			insertExplodingActivity();
		}
	}
</script>
</html>
